ept: Put locks around ept_get_entry
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 30 Aug 2010 07:39:52 +0000 (08:39 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 30 Aug 2010 07:39:52 +0000 (08:39 +0100)
commit5c3f41d408cb14a9bc5a2a53f3ccd082447ab051
tree539034560ab2e0ee5a5146197a2645f505fd8768
parentd644899c1cf196852018ff71ad5b620f0036cc04
ept: Put locks around ept_get_entry

There's a subtle race in ept_get_entry, such that if tries to read an
entry that ept_set_entry is modifying, it gets neither the old entry
nor the new entry, but empty.  In the case of multi-cpu
populate-on-demand guests, this manifests as a guest crash when one
vcpu tries to read a page which another page is trying to populate,
and ept_get_entry returns p2m_mmio_dm.

This bug can also be fixed by making both ept_set_entry and
ept_next_level access-once (i.e., ept_next_level reads full ept_entry
and then works with local value; ept_set_entry construct the entry
locally and then sets it in one write).  But there doesn't seem to be
any major performance implications of just making ept_get_entry use
locks; so the simpler, the better.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/arch/x86/mm/hap/p2m-ept.c